package com.jame.basics.thread.juc;

import java.util.concurrent.ExecutionException;

public class MyThreadTest {


    int count = 100;

    public static void main(String[] args) throws InterruptedException, ExecutionException {
        MyThreadTest test = new MyThreadTest();

        new Thread(() -> {
            for (int j = 0; j < 35; j++) {
                test.sell();
            }
        }).start();
        new Thread(() -> {
            for (int j = 0; j < 35; j++) {
                test.sell();
            }
        }).start();
        new Thread(() -> {
            for (int j = 0; j < 35; j++) {
                test.sell();
            }
        }).start();

    }

    public void sell() {
        if (count < 0) {
            System.out.println("票卖完了");
            return;
        }
        System.out.println(Thread.currentThread().getName() + ":买到了一张票,还剩" + (--count) + "张");


    }

}
